<?php
include("connect.php");
?>

<?php
$css = '<link rel="stylesheet" type="text/css" media="all" href="asset/css/class_myprofile.css">';
$title = 'My Profile';
$pagename = 'my_profile';
$userid = $_SESSION['userid'];
if(isset($_REQUEST['userprofileid']))
	$userid = $_REQUEST['userprofileid'];
?>

<?php
$sql = "select user_category from m_user where user_id=".$_SESSION['userid'];
$retval = mysql_query( $sql, $con );
while($row = mysql_fetch_array($retval))
	{
		$user_category = $row[0];
	}
if(isset($_SESSION["userid"]))
	{
		if($user_category ==9)
		{
			include("header_loggedinadmin.php");
		}else
		{
			include("header_loggedin.php");
		}
	}
else
{
	echo '<script>';
		echo "alert('Please Login!');";
		echo 'window.location = "index.php"';
		echo '</script>';
}

?>

<?
$sql = "select fname,lname,phonenumber,jcu_email,fb_account,twitter_account,address,course_id,course_category_id,postcode,nationality from m_user where user_id = ".$userid;
$retval = mysql_query( $sql, $con );
	if(! $retval )
	{
  		die('Could not get data: ' . mysql_error());
	}
	while($row = mysql_fetch_array($retval))
	{
		$name = $row[fname]." ".$row[lname];
		$phone = $row[phonenumber];
		$email = $row[jcu_email];
		$fb = $row[fb_account];
		$twit = $row[twitter_account];
		$add= $row[address];
		$course=$row[course_id];
		$course_cat=$row[course_category_id];
		$postcode=$row[postcode];
		$nationality=$row[nationality];
		$userphoto = $userid;
		
	}
?>
<script type="text/javascript" >
$(function() {
$(".submit").click(function() 
{
var name = $("#name").val();
var email = $("#email").val();
var comment = $("#comment").val();
var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment;
if(name=='' || email=='' || comment=='')
{
alert('Please Give Valid Details');
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />Loading Comment...');
$.ajax({
type: "POST",
url: "commentajax.php",
data: dataString,
cache: false,
success: function(html){
$("ol#update").append(html);
$("ol#update li:last").fadeIn("slow");
$("#flash").hide();
}
});
}return false;
}); });
</script>

<div id="blue_bg">
	<div id="main">
        <div class="wrapper">
        	<div id="content">
            	<div id="white_box">
                	<h3 class="flag_long">MY PROFILE &nbsp;&nbsp;
                	<?php
                		if($userid == $_SESSION["userid"])
                		{
                			echo '<a href="edit_profile.php">
                	<img src="images/my_profile/edit-profile-btn.png" /></a>';
                		}
                	?></h3>
                	<?php
						$userid = $_SESSION["userid"];
						$query = "select photolink from m_user where user_id =".$userphoto;
						$result = mysql_query($query);
    					while($row = mysql_fetch_array($result))
						{
							$photolink =$row[0];
						}
						echo '<div id="photo_box"><img src="images/my_profile/'.$photolink.'" width=214 height =321 /></div>';
					?>

                    
                    <div id="profile_box">
                        <table>
                            <tr>
                                <td><span class="bold">Name</span></td>
                                <td width="50px"></td>
                                <td><?php echo $name;?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">Address</span></td>
                                <td width="50px"></td>
                                <td><?php echo $add;?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">Post Code</span></td>
                                <td width="50px"></td>
                                <td>55285</td>
                            </tr>
                            <tr>
                                <td><span class="bold">Mobile Phone</span></td>
                                <td width="50px"></td>
                                <td><?php echo $phone;?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">E-mail</span></td>
                                <td width="50px"></td>
                                <td><?php echo $email;?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">Nationality</span></td>
                                <td width="50px"></td>
                                <td>Indonesian</td>
                            </tr>
                            <tr>
                                <td><span class="bold">Course</span></td>
                                <td width="50px"></td>
                                <td><?php
									$sql2 = "SELECT a.category_name, b.category_detail_name from t_category a join t_detail_category b on a.category_id=b.category_id where b.category_detail_id=".$course_cat;

									$ret_cat=mysql_query($sql2);
									
									if($ret_cat){
										$course_name=mysql_fetch_array($ret_cat);
											echo $course_name[category_name];
								?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">Course Category</span></td>
                                <td width="50px"></td>
                                <td><?php
										echo $course_name[category_detail_name];
										}
									
								
								?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">Facebook E-mail</span></td>
                                <td width="50px"></td>
                                <td><?php echo $fb;?></td>
                            </tr>
                            <tr>
                                <td><span class="bold">Twitter ID</span></td>
                                <td width="50px"></td>
                                <td><?php echo $twit;?></td>
                            </tr>
                            <!--<tr>
                                <td></td>
                                <td width="50px"></td>
                                <td><input type="submit" value="" id="submit_btn" /></td>
                            </tr>-->
                        </table>
           			</div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php
include("footer.php");
?>

